package cn.cxion.chat.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import cn.cxion.chat.R;
import cn.cxion.chat.app.activity.ConstantActivity;
import cn.cxion.chat.app.bean.AppointmentInfo;
import cn.cxion.chat.app.constant.Constant;
import cn.cxion.chat.app.view.AddScheduleView;
import cn.cxion.chat.app.view.ScheduleItemView;

public class ScheduleAdapter extends RecyclerView.Adapter<ScheduleViewHolder> {

    private Context context;
    private List<AppointmentInfo> list;

    public ScheduleAdapter(Context context) {
        this.context=context;
    }

    public void setList(List<AppointmentInfo> list) {
        this.list = list;
    }

    ScheduleItemView itemView;
    @NonNull
    @Override
    public ScheduleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        itemView=new ScheduleItemView(context);
        return new ScheduleViewHolder(itemView.getView());
    }

    @Override
    public void onBindViewHolder(@NonNull ScheduleViewHolder holder, int position) {
            holder.llHold.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ConstantActivity.show(context,Constant.ADDSCHEDULE,list.get(position));
                }
            });
//        holder.tvTitle.setText("标题："+list.get(position).getContent());
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }


}
